<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:c="livcos.org/ns/cosmos"
  xmlns:u="livcos.org/ns/cosmos/update"
  xmlns="livcos.org/ns/pm/log"
  exclude-result-prefixes="c">
  
  <xsl:param name="ref"/>
  <xsl:param name="time" select="current-dateTime()"/>
  <xsl:param name="duration" select="10"/>
  <xsl:param name="id"/>
  
  <xsl:template match="/">
    <u:context ref="/livcos.org/WorkLog/data/Log" scope="content">
      <xsl:apply-templates select="*/c:request/parameter/*" />
    </u:context>
    <job:feed xmlns:job="livcos.org/ns/process/job" ref="/livcos.org/WorkLog/web/Log"
      stream="response" base="job"/>
  </xsl:template>
  
  <xsl:template match="*">
    <u:insert select=".">
      <xsl:apply-templates select="." mode="content"/>
    </u:insert>
  </xsl:template>
  
  <xsl:template match="*" mode="content">
  </xsl:template>
  
  <xsl:template match="in" mode="content">
    <in id="{{new-id()}}" ref="{$ref}" time="{$time}"/>
  </xsl:template>
  
  <xsl:template match="out" mode="content">
    <out id="{{new-id()}}" ref="{$ref}" time="{$time}"/>
  </xsl:template>
  
  <xsl:template match="break" mode="content">
    <break id="{{new-id()}}" duration="{$duration}" time="{$time}"/>
  </xsl:template>
  
  <xsl:template match="connect" mode="content">
    <connect id="{{new-id()}}" host="{../../interface[@role = 'remote']/@host}" time="{$time}"/>
  </xsl:template>
  
  <xsl:template match="disconnect" mode="content">
    <disconnect id="{{new-id()}}" host="{../../interface[@role = 'remote']/@host}" time="{$time}"/>
  </xsl:template>
  
  <xsl:template match="delete">
    <u:delete select="*[@id = '{$id}']" />
  </xsl:template>
  
  
</xsl:stylesheet>
